<template>
  <div v-if="modalStatus" class="show-modal">
    <div class="dataChat-dialog">
      <div class="left-arrow" @click.stop="reduceIndex">
        <img
          class="left-arrow-icon left-arrow-icon"
          src="https://storage.djyanbao.com/dj-static/web/20240318014741/img/previous.9e553def.png"
          alt=""
        />
      </div>
      <div class="mid-div">
        <div class="close" @click="modalStatus = false">
          <img src="@/assets/images/close-modal.png" alt="关闭" />
        </div>
        <div class="name">{{ chart.name }}</div>
        <div class="mid-img">
          <el-image :src="chart.online_url" fit="contain" :alt="chart.name" />
        </div>
        <div class="chart-tag">
          <div>
            {{ chart.type.name }} | {{ chart.industry.name }} | {{ chart.fid }}
          </div>
          <div>发布时间：{{ chart.time_text }}</div>
        </div>
        <div class="chart-sep"></div>
        <div class="chart-source">
          <a class="chart-file" :href="'/detail/' + chart.fid" target="_blank"
            >来源报告：{{ chart.filename }}</a
          >
          <a
            class="chart-original"
            :href="'/detail/' + chart.fid"
            target="_blank"
            >原文定位</a
          >
        </div>
      </div>
      <div class="left-arrow" @click.stop="addIndex">
        <img
          class="left-arrow-icon"
          src="https://storage.djyanbao.com/dj-static/web/20240318014741/img/next.b5a0ac87.png"
          alt=""
        />
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  data() {
    return {};
  },
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    chartList: {
      type: Array,
    },
    chartIndex: {
      type: Number,
      default: 0,
    },
  },
  computed: {
    ...mapGetters(["sid", "is_vip"]),
    modalStatus: {
      get() {
        return this.value;
      },
      set(value) {
        this.$emit("input", value);
      },
    },
    chart: function () {
      return this.chartList[this.chartIndex];
    },
  },
  watch: {
    // chartList: function (n, o) {
    //   if (n) {
    //     this.chartIndex = this.chartList.findIndex((item) => {
    //       return item.online_url == this.infoImg;
    //     });
    //   }
    // },
  },
  methods: {
    addIndex() {
      if (this.chartIndex < this.chartList.length - 1) {
        this.chartIndex++;
      }
    },
    reduceIndex() {
      if (this.chartIndex > 0) {
        this.chartIndex--;
      }
    },
    toDetail(fid) {},
  },
};
</script>

<style lang='less' scoped>
.dataChat-dialog {
  height: 100%;
  width: calc(100% - 200px);
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  justify-content: center;
  align-items: center;
}
.left-arrow {
  width: 60px;
  height: 60px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 20px;
}
.left-arrow-icon {
  width: 100%;
  height: 100%;
  display: block;
}
.left-arrow-icon-rotate {
  transform: rotate(-180deg);
}
.mid-div {
  max-width: 800px;
  width: 100%;
  background-color: #ffffff;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px;
  box-sizing: border-box;
  position: relative;
}

.close {
  position: absolute;
  top: 0;
  right: -60px;
  width: 60px;
  height: 60px;
}

.close img {
  width: 100%;
  height: 100%;
}

.name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 60px;
}

.mid-img {
  width: 100%;
  height: 64%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mid-img .el-image {
  width: 100%;
  height: 100%;
}

.chart-tag {
  width: 100%;
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  height: 34px;
  color: #aaa;
  font-size: 13px;
}

.chart-sep {
  width: 100%;
  height: 1px;
  background-color: #e9e9e9;
}

.chart-source {
  width: 100%;
  color: #333;
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-height: 32px;
}

.chart-file {
  width: 80%;
  font-size: 14px;
  line-height: 16px;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; /* 这里是超出几行省略 */
  overflow: hidden;
  text-decoration: none;
  color: #333;
}
.chart-original {
  font-size: 14px;
  line-height: 24px;
  color: rgb(255, 255, 255);
  text-align: center;
  border-radius: 5px;
  font-family: "微软雅黑", "Arial";
  background: rgb(110, 116, 200);
  text-decoration: none;
  padding: 6px 10px;
}

.mid-text {
  width: 720px;
  height: 112px;
  border-top: 1px solid #eeeeee;
  padding: 20px;
}
.dialog-text {
  font-size: 16px;
  color: #3f4750;
}
.dialog-title {
  font-size: 14px;
  font-weight: 600;
  color: #467dd0;
}
.show-modal {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
